// create.js
Page({
  data: {
    title: '',
    content: ''
  },

  onTitleInput(e) {
    this.setData({ title: e.detail.value });
  },

  onContentInput(e) {
    this.setData({ content: e.detail.value });
  },

  saveNote() {
    const notes = wx.getStorageSync('notes') || [];
    const newNote = {
      id: new Date().getTime().toString(),
      title: this.data.title,
      content: this.data.content
    };
    notes.push(newNote);
    wx.setStorageSync('notes', notes);
    this.refreshApp();
  },

  cancelNote() {
    wx.navigateBack();
  },

  refreshApp() {
    wx.switchTab({
      url: '/pages/note/note'
    });
  }
});

